package com.myapp.controller;

import com.myapp.dao.TUserMapper;
import com.myapp.entity.TUser;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Locale;

/**
 * Handles requests for the application home page.
 */
@Controller
public class HomeController {

    @Autowired
    TUserMapper tUserMapper;

    @GetMapping("/")
    @ResponseBody
    public String home(Locale locale, Model model, HttpServletRequest request) {
        return "hello";
    }

    @GetMapping("/selectByName")
    @ResponseBody
    public String selectByName() {
        TUser tUser = tUserMapper.selectByName("张三");
        TUser user = tUserMapper.getById(1);
        return tUser.toString() + user;
    }

    @GetMapping("/findByIdAfter")
    @ResponseBody
    public List<TUser> findByIdAfter(int id) {
        return tUserMapper.findByIdAfter(id);
    }

}
